package com.bee.baselibrary.utils;

import java.lang.reflect.UndeclaredThrowableException;

/**
 * 获取Throwable里头的错误信息 
 * created by 魏霖涛 on 2017/10/26 0026 
 */  
public class ThrowableMessageUtil {  
    public static String getMessage(Throwable e){
        String msg = null;
        if (e instanceof UndeclaredThrowableException){
            Throwable targetEx = ((UndeclaredThrowableException) e).getUndeclaredThrowable();
            if (targetEx !=null ){
                msg = targetEx.getMessage();  
            }  
        } else {  
            msg = e.getMessage();  
        }  
        return msg;  
    }  
}  